<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<jsp:include page="/jsp/login/business/sysManagement/flow/head.jsp">
    			<jsp:param name="formName" value="frm"/>
    		</jsp:include>
    		<s:hidden name="vacation.id" id="vacationId"></s:hidden>
    		<s:hidden name="vacation.employee.id" id="employeeId"></s:hidden>
    		<table width="90%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr bgcolor="#FFFFFF">
    				<td width="15%" class="label" align="right">
    					申请人编号：
    				</td>
    				<td width="35%" align="left">
    					<div id="employeeNumDiv" style="display:inline-block; float:left;">
    						<s:property value="vacation.employee.employeeNum"/>
    					</div>
    					&nbsp;
    					<input name="applicant" id="saveDocBtn" type="button" value="选择" class="btn" onclick="selectEmployee()" />
    				</td>
    				<td width="15%" class="label" align="right">
    					申请人：
    				</td>
    				<td width="35%" align="left">
    					<div id="employeeNameDiv" style="display:inline-block">
    						<s:property value="vacation.employee.employeeName"/>
    					</div>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td class="label" align="right">
    					开始时间：
    				</td>
    				<td align="left">
    					<input style="width:120px" type="text" name="vacation.fromTimeStr" id="fromTime" class="WDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" value="<s:date name="vacation.fromTime" format="yyyy-MM-dd HH:mm" />" onblur="computeTime()" />
    				</td>
    				<td class="label" align="right">
    					结束时间：
    				</td>
    				<td align="left">
    					<input style="width:120px" type="text" name="vacation.toTimeStr" id="toTime" class="WDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" value="<s:date name="vacation.toTime" format="yyyy-MM-dd HH:mm" />" onblur="computeTime()" />
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td class="label" align="right">
    					多少天：
    				</td>
    				<td align="left">
    					<s:textfield readonly="true" name="vacation.days" id="days" cssStyle="width:120px"></s:textfield>
    				</td>
    				<td class="label" align="right">
    					多少小时：
    				</td>
    				<td align="left">
    					<s:textfield readonly="true" name="vacation.hours" id="hours" cssStyle="width:120px"></s:textfield>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td class="label" align="right">
    					
    				</td>
    				<td align="left">
    					<s:select id="s1" name="s1" list='#{"test":"测试"}'></s:select>
    					<input id="r1" name="r1" type="radio" value="1" checked="checked" /> 一
    					<input id="r2" name="r1" type="radio" value="2" /> 二
    					<input id="c1" name="c1" type="checkbox" value="1" /> 三
    					<input id="c2" name="c1" type="checkbox" value="2" checked="checked" /> 四
    				</td>
    				<td class="label" align="right">
    					
    				</td>
    				<td align="left">
    					
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td class="label" align="right">
    					备注：
    				</td>
    				<td colspan="3" align="left">
    					<s:textarea cssStyle="width:700px; height:200px" name="vacation.remark" id="remark"></s:textarea>
    				</td>
    			</tr>
    		</table>
    		
    		<jsp:include page="/jsp/login/business/sysManagement/flow/tail.jsp"></jsp:include>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function saveObj(refresh)
    {
        if(validate() == false)
        {
            return false;
        }
        var url = 'inner/vacation/saveVacation.action';
        ajaxAction(url, 'post', 'frm', true, function(docId){
        	if(refresh)
        	{
            	var url = realPath + '/inner/vacation/toSaveVacation.action?vacation.id=' + docId;
            	window.location.href = url;
        	}
        });
        return true;
    }

    function submitCallback()
    {
    	var url = realPath + '/inner/vacation/vacationManage.action?lvvo.listCode=business_vacation';
    	window.location.href = url;
    }

    function validate()
    {
        var employeeId = $('#employeeId');
        var fromTime = $('#fromTime');
        var toTime = $('#toTime');
        if(!isNotNull(employeeId.val()))
        {
            showMsg('申请人不能为空。', function(){employeeId.focus();});
            return false;
        }
        if(!isNotNull(fromTime.val()))
        {
            showMsg('开始时间不能为空。', function(){fromTime.focus();});
            return false;
        }
        if(!isNotNull(toTime.val()))
        {
            showMsg('结束时间不能为空。', function(){toTime.focus();});
            return false;
        }
        if(fromTime.val() > toTime.val())
        {
        	showMsg('开始时间不能大于结束时间。', function(){toTime.focus();});
            return false;
        }
        return true;
    }

    function computeTime()
    {
        var fromTime = $('#fromTime');
        var toTime = $('#toTime');
        if(isNotNull(fromTime.val()) && isNotNull(toTime.val()))
        {
	        var fromDate = parseDate(fromTime.val());
	        var toDate = parseDate(toTime.val());
	        var result = subTime(fromDate, toDate);
	        var days = $('#days');
	        var hours = $('#hours');
	        days.val(result.days);
	        hours.val(result.hours);
        }
    }

    function selectEmployee()
    {
    	var url = realPath + '/inner/masterData/toSelectEmployee.action?lvvo.listCode=master_data_selectEmployee';
    	var employee = showMd(url, 800, 500, 'yes', 'yes');
    	if(employee != null)
    	{
			var employeeId = $('#employeeId');
			var employeeNumDiv = $('#employeeNumDiv');
			var employeeNameDiv = $('#employeeNameDiv');
			employeeId.val(employee.id);
			employeeNumDiv.text(employee.employeeNum);
			employeeNameDiv.text(employee.employeeName);
    	}
    }

    </script>
  </body>
</html>
